package com.kkang.ch2.event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 自定义事件监听器
 *
 * @author yongk_liu
 **/
@Component//被spring管理，始终监听相应事件
public class DemoListener implements ApplicationListener<DemoEvent> {//对event的监听器

    @Override
    public void onApplicationEvent(DemoEvent event) {//监听方法
        String msg = event.getMsg();
        System.out.println("我（bean-demoListener）接收到了bean-demoPublisher发布的消息：" + msg);
    }

}
